/*睡眠，注意调用这个函数的函数需要被async标识
* 例如：
*
async function run(){
 await sleep(2000);
}
* */
export function sleep(time) {
    return new Promise((resolve) => setTimeout(resolve, time));
}

export function getNullFiltration(obj) {
    return Object.fromEntries(
        Object.entries(obj)
            .filter(([key, value]) => value !== null && value !== undefined && Object.keys(value).length !== 0)
    )
}
/*判断两个对象是否相等（属性和属性值完全一样）*/
export function isObjectValueEqualNew(a, b) {
    var aProps = Object.getOwnPropertyNames(a);
    var bProps = Object.getOwnPropertyNames(b);
    if (aProps.length != bProps.length) {
        return false;
    }
    for (var i = 0; i < aProps.length; i++) {
        var propName = aProps[i]

        var propA = a[propName]
        var propB = b[propName]
        if ((typeof (propA) === 'object')) {
            if (this.isObjectValueEqualNew(propA, propB)) {
                return true
            } else {
                return false
            }
        } else if (propA !== propB) {
            return false
        } else {
            //
        }
    }
    return true
}
